import urllib.request
import urllib.parse
import json

#这个只是一个post方法测试
def postDemo(url):
    # url = "http://10.108.6.84:28060/api/user/noauth/login"
    header = {
        "User-Agent": "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36",
        "Accept": "application/json, text/plain, */*",
        "Content-Type": "application/json;charset=UTF-8"}
    formatData = {"form": 3, "operateCode": "", "operateName": "", "token": "", "time": 1534485913474,
                  "reqData": {"operName": "汪延军", "operPassword": "123456"}, "sign": "0E3A424F6641FF567814A5FC6526872E"}
    mydata = urllib.parse.urlencode(formatData).encode('utf-8')
    req = urllib.request.Request(url, data=mydata, headers=header)
    data = urllib.request.urlopen(req).read()
    print("============")
    print(data)

def getDemo():
    url = "http://10.108.6.84:28060/api/user/noauth/login"
    header = {
        "User-Agent": "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36",
        "Accept": "application/json, text/plain, */*",
        "Content-Type": "application/json;charset=UTF-8"}
    req = urllib.request.Request(url)
    data = urllib.request.urlopen(req).read()
    print("============")
    print(data)

